package pacificlms;

import java.sql.Connection;
import pacificlms.Error.ErrorHandle;

/**
 * Singleton containing the connection to the database
 * @author Brian Hume
 */
public class MasterConnection//Singleton
{
    /**
     * Sets the master connection
     * @param Con The connection to set as the master connection to the database
     * @throws Exception When the connection has already been initialized will throw an exception
     */
    public static void Initialize(Connection Con)
    {
        if (Connection == null)
        {
            Connection = Con;
        }
        else
        {
            Connection = Con;
            ErrorHandle.Display("Connection Success Error", "Connection initialized multiple times using latest", null, true);
        }
    }
    
    /**
     * Returns an instance of the connection to the database
     * @return instance of the connection to the database
     */
    public static Connection getInstance() 
    {
        return Connection;
    }
    
    private static Connection Connection = null;
}
